<!DOCTYPE html>
<html>

<head>


    {include file="Public/header"}


    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">

</head>

<body class="white-bg" style="padding: 3px;font-size: 13px;overflow-x:auto">
<div class="page-heade">
    <h2 class="title_color text-center">默认考勤信息</h2>
</div>
<table class="table table-bordered bud_hei">
    <tr class="info text-center">
        <td>上班时间</td>
        <td>上班地点</td>
        <td>上班经度</td>
        <td>上班纬度</td>
        <td>下班时间</td>
        <td>下班地点</td>
        <td>下班经度</td>
        <td>下班纬度</td>
        <td>设定时间</td>
        <td>最后修改人</td>
        <td>操作</td>
    </tr>
    <tr>
        <td>{:isset($mrkq.sbsj)?$mrkq.sbsj:''}</td>
        <td>{:isset($mrkq.sbdd)?$mrkq.sbdd:''}</td>
        <td>{:isset($mrkq.sbjd)?$mrkq.sbjd:''}</td>
        <td>{:isset($mrkq.sbwd)?$mrkq.sbwd:''}</td>
        <td>{:isset($mrkq.xbsj)?$mrkq.xbsj:''}</td>
        <td>{:isset($mrkq.xbdd)?$mrkq.xbdd:''}</td>
        <td>{:isset($mrkq.xbjd)?$mrkq.xbjd:''}</td>
        <td>{:isset($mrkq.xbwd)?$mrkq.xbwd:''}</td>
        <td>{:isset($mrkq.ctime)?$mrkq.ctime:''}</td>
        <td>{:isset($mrkq.cuser_name)?$mrkq.cuser_name:''}</td>
        <td><a href="javascript:;" id="setdefaultInfo">设置</a></td>
    </tr>
</table>
<div class="page-heade">
    <h2 class="title_color text-center">查看所有考勤信息</h2>
</div>
<form action="" class="form-inline" id="form1">
    <table class="table table-bordered bud_hei" style="margin-bottom: 0">
        <tr>
            <td class="text-right">分组名称</td>
            <td><input type="text" name="fzmc" class="form-control" value="{$fzmc}"></td>
            <td class="text-right">职员姓名</td>
            <td><input type="text" name="ygxm" class="form-control" value="{$ygxm}"></td>
            <td class="text-left">
                <button class="btn-sm btn-info btn">查询</button>
                <span class="lr_5"></span>
                <button class="btn-sm btn-info btn" type="reset" id="reset">清空查询条件</button>
            </td>
        </tr>
    </table>
</form>
<div class="padding-10">
    <a href="javascript:;" class="btn btn-sm btn-info" id="addkaoqinfz">新增考勤分组</a>
</div>
<table class="table table-striped table-bordered table-hover bud_hei text-center" style="width: 100%;">
    <tr class="info">
        <th class="text-center">No.</th>
        <th class="text-center">分组名称</th>
        <th class="text-center">上班时间</th>
        <th class="text-center">上班地点</th>
        <th class="text-center">下班时间</th>
        <th class="text-center">下班地点</th>
        <th class="text-center">包含人数</th>
        <th class="text-center">创建人</th>
        <th class="text-center">创建时间</th>
        <th class="text-center">修改人</th>
        <th class="text-center">修改时间</th>
        <th class="text-center">操作</th>
    </tr>
    <tbody>
    {volist name="data" id="row" key="k"}
    <tr>
        <td>{$k}</td>
        <td>{$row.title}</td>
        <td>{$row.sbsj}</td>
        <td class="gystext">{$row.sbdd}</td>
        <td>{$row.xbsj}</td>
        <td class="gystext">{$row.xbdd}</td>
        <td><a href="{:url('clockingfzlidt',['id'=>$row.id])}">{$row.cnt}</a></td>
        <td>{$row.cuser}</td>
        <td>{$row.ctime}</td>
        <td>{$row.euser}</td>
        <td>{$row.etime}</td>
        <td><a href="javascript:;" class="update" data-id="{$row.id}">修改</a>&nbsp;<a href="javascript:;" class="delete" data-id="{$row.id}">删除</a></td>
    </tr>
    {/volist}
    </tbody>
</table>
<h5 class="text-center"  style="font-size: 13px;font-weight: 500">
            <!-- 总共有12条记录，第1/2页,当前页<input id="page" type="text"  style="width: 40px" value="1"/><span id="gopage">Go</span>&nbsp;&nbsp;<span id="fistpage">首页</span>&nbsp;&nbsp;
             每页显示
    <select id="pagesize">
        <option value='10' selected>10条</option>
        <option value='15'>15条</option>
        <option value='20'>20条</option>
    </select>-->
    {$page}
</h5>
<!--    <h3 class="text-center"><img src="__STATIC__/layout/img/zwsj.png"></h3> -->
<div class="ibox-content" style="display: none;" id="addlaborcontractDiv">
    <input type="text" style="width: 120px;display: inline-block;" class="form-control">
    <button class="btn btn-sm btn-info" type="button">搜索</button>
    <div class="" style="height: 300px"></div>
    <h2 style="font-size: 16px">指掌云软件</h2>
    <form action="" class="form-inline" id="mrkqxx">
        <table class="table table-bordered">
            <tr>
                <td style="width: 120px">上班地点<span class="colorRed">*</span></td>
                <td colspan="5"><input type="text" class="form-control" name="sbdd" value="{:isset($mrkq.sbdd)?$mrkq.sbdd:''}" size="45"></td>
            </tr>
            <tr>
                <td style="width: 120px">上班时间<span class="colorRed">*</span></td>
                <td><input type="text" class="form-control" id="startsban" name="sbsj" value="{:isset($mrkq.sbsj)?$mrkq.sbsj:''}"></td>
                <td>上班经度</td>
                <td><input type="text" class="form-control" size="16" readonly  name="sbjd" value="{:isset($mrkq.sbjd)?$mrkq.sbjd:''}"></td>
                <td>上班纬度</td>
                <td><input type="text" class="form-control" size="16" readonly value="{:isset($mrkq.sbwd)?$mrkq.sbwd:''}" name="sbwd"></td>
            </tr>
            <tr>
                <td style="width: 120px">下班地点<span class="colorRed">*</span></td>
                <td colspan="5"><input type="text" class="form-control" value="{:isset($mrkq.xbdd)?$mrkq.xbdd:''}" size="45" name="xbdd"></td>
            </tr>
            <tr>
                <td style="width: 120px">下班时间<span class="colorRed">*</span></td>
                <td><input type="text" class="form-control" id="endxban" name="xbsj" value="{:isset($mrkq.xbsj)?$mrkq.xbsj:''}"></td>
                <td>上班经度</td>
                <td><input type="text" class="form-control" size="16" readonly value="{:isset($mrkq.xbjd)?$mrkq.xbjd:''}" name="xbjd"></td>
                <td>上班纬度</td>
                <td><input type="text" class="form-control" size="16" readonly value="{:isset($mrkq.xbwd)?$mrkq.xbwd:''}" name="xbwd"></td>
            </tr>
        </table>
    </form>
</div>

<div class="ibox-content" style="display: none;" id="addkaoqinfzDiv">
    <input type="text" style="width: 120px;display: inline-block;" class="form-control">
    <button class="btn btn-sm btn-info" type="button">搜索</button>
    <div class="" style="height: 300px"></div>
    <h2 style="font-size: 16px">指掌云软件</h2>
    <form action="" class="form-inline" id="form2">
        <table class="table table-bordered">
            <tr>
                <td>分组名称<span class="colorRed">*</span></td>
                <td colspan="5"><input type="text" class="form-control" name="title" id=""></td>
            </tr>
            <tr>
                <td>员工姓名<span class="colorRed">*</span></td>
                <td colspan="5">
                    <div style="float:left;">
                    <div class="input-group">
                        <input id="area_id" type="text" placeholder="请输入关键字或空格查询"
                               class="form-control" value="" style="min-width: 300px;width: 300px">
                        <div class="input-group-btn">
                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                            </ul>
                        </div>
                    </div>
                    </div>
                    <a href="javascript:;" style="float:left;" id="select_area" class="btn btn-primary btn-sm">选择</a>
                </td>
            </tr>
            <tr>
                <td></td>
                <td colspan="5">
                    <div id="renyuan" class="duoxuan"></div>
                </td>
            </tr>
            <tr>
                <td style="width: 120px">上班地点<span class="colorRed">*</span></td>
                <td colspan="5"><input type="text" name="sbdd" class="form-control" value="上海市上海市黄兴路217号二钢明珠楼A座"
                                       size="45">
                    <button class="btn btn-info btn-sm" type="button">清除上班地址</button>
                </td>
            </tr>
            <tr>
                <td style="width: 120px">上班时间<span class="colorRed">*</span></td>
                <td><input type="text" class="form-control" name="sbsj"  id="startsban"></td>
                <td>上班经度</td>
                <td><input type="text" class="form-control" size="16" readonly name="sbjd" value="113.355477"></td>
                <td>上班纬度</td>
                <td><input type="text" class="form-control" size="16" readonly name="sbwd" value="23.005477"></td>
            </tr>
            <tr>
                <td style="width: 120px">下班地点<span class="colorRed">*</span></td>
                <td colspan="5"><input type="text" name="xbdd" class="form-control" value="上海市上海市黄兴路217号二钢明珠楼A座"
                                       size="45">
                    <button class="btn btn-info btn-sm" type="button">清除下班地址</button>
                </td>
            </tr>
            <tr>
                <td style="width: 120px">下班时间<span class="colorRed">*</span></td>
                <td><input type="text" class="form-control" name="xbsj" id="endxban"></td>
                <td>下班经度</td>
                <td><input type="text" class="form-control" size="16" readonly value="113.355477" name="xbwd"></td>
                <td>下班纬度</td>
                <td><input type="text" class="form-control" size="16" readonly value="23.005477" name="xbjd"></td>
            </tr>
        </table>
    </form>
</div>
<!-- 全局js -->
<script src="__STATIC__/layout/js/jquery.min.js"></script>
<script src="__STATIC__/layout/js/contabs_sub.js"></script>
<script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
<!-- Sweet alert -->
<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>

<script src="__STATIC__/layout/js/contabs_sub.js"></script>
<script>
    $(function () {
        $('body').on('click', 'input[type=text]', function () {
            this.select()
        })
        $('.update').on('click',function () {
            var id = $(this).data('id')
            $.post('',{id:id},)
        })
    })
</script>
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
<script src="__STATIC__/layout/js/plugins/laydate/laydate.js"></script>
<script>
    $(document).ready(function () {
        // $("#checkmyrecord").click(function(){
        //     var str='<div class="ibox-content"><form class="form-inline"><table class="table table-bordered bud_hei"><tr><td style="width:100px">员工姓名:</td><td colspan="7">张晓明</td></tr><tr><td>上班地点:</td><td>广东省广州市番禺区番禺大道北辅路</td><td style="width:100px">上班时间:</td><td>09:00</td><td style="width:100px">上班经度:</td><td>113.148923</td><td style="width:100px">上班纬度:</td><td>213.148923</td></tr><tr><td>上班地点:</td><td>广东省广州市番禺区番禺大道北辅路</td><td style="width:100px">下班时间:</td><td>18:00</td><td style="width:100px">下班经度:</td><td>113.148923</td><td style="width:100px">下班纬度:</td><td>213.148923</td></tr></table><div class="padding-10 text-center"><button class="btn btn-warning">关闭</button></div></form></div>'
        //      layer.open({
        //         type: 1,
        //         title: '查看考勤信息',
        //          area: ['1000px', '400px'],
        //         fixed: false, //不固定
        //         maxmin: true,
        //         content: str
        //     });
        //     return false
        // })


        $('#reset').on('click', function () {
            $("#form1 input").each(function () {
                $(this).val('');
            });
            $("#form1 select").each(function () {
                $(this).val('');
            });
//            $('#form1').submit()
            return false
        })
    })

    $(document).ready(function () {
        var $gysText = $(".gystext");
        var num = 3;
        $gysText.each(function () {
            wordlimit($(this), num)
        })
    })

    /*超出省略*/
    function wordlimit(cname, num) {
        for (var i = 0; i < cname.length; i++) {
            var nowLength = cname[i].innerHTML.length;
            if (nowLength > num) {
                return cname[i].innerHTML = cname[i].innerHTML.substr(0, num) + '...'
            }
        }
    }


    /*设置默认考勤信息*/
    $("#setdefaultInfo").click(function () {
        layer.open({
            type: 1,
            title: '设置默认考勤信息',
            area: ['750px', '550px'],
            fixed: false, //不固定
            maxmin: true,
            content: $('#addlaborcontractDiv'),
            btn: ["提交", "返回"],
            yes: function (i, o) {
                var param = $('#mrkqxx').serialize()
                $.post('{:url("mrkqsz")}', param, function (data) {
                   if (data.success) {
                       swal({title: data.msg}, function () {
                           layer.close(i)
                           location.reload()
                       })
                   } else {
                       swal(data.msg)
                   }
                }, 'json')
            }
        });

    })

    /*新增考勤分组*/
    $("#addkaoqinfz").click(function () {
        layer.open({
            type: 1,
            title: '设置考勤信息',
            area: ['950px', '550px'],
            fixed: false, //不固定
            maxmin: true,
            content: $('#addkaoqinfzDiv'),
            btn: ["提交", "返回"],
            yes: function (i, o) {
                var param = $('#form2').serialize()
                $.post('{:url("add")}', param, function (data) {
                    if (data.success) {
                        swal({title: data.msg}, function () {
                            layer.close(i)
                            location.reload()
                        })
                    } else {
                        swal(data.msg)
                    }
                }, 'json')
            }
        });
    })
    /*新增考勤分组*/
    $(".update").click(function () {
        var id = $(this).data('id')
        layer.open({
            type: 1,
            title: '设置考勤信息',
            area: ['950px', '550px'],
            fixed: false, //不固定
            maxmin: true,
            content: $('#addkaoqinfzDiv'),
            btn: ["提交", "返回"],
            success:function () {
                //查询考勤
                $.getJSON('{:url("update")}',{id:id},function (data) {
                    $('#addkaoqinfzDiv [name=title]').val(data.title)
                    $('#addkaoqinfzDiv [name=sbdd]').val(data.sbdd)
                    $('#addkaoqinfzDiv [name=sbsj]').val(data.sbsj)
                    $('#addkaoqinfzDiv [name=sbjd]').val(data.sbjd)
                    $('#addkaoqinfzDiv [name=sbwd]').val(data.sbwd)
                    $('#addkaoqinfzDiv [name=xbdd]').val(data.xbdd)
                    $('#addkaoqinfzDiv [name=xbsj]').val(data.xbsj)
                    $('#addkaoqinfzDiv [name=xbwd]').val(data.xbwd)
                    $('#addkaoqinfzDiv [name=xbjd]').val(data.xbjd)
                    $('#addkaoqinfzDiv #renyuan').html(data.ygxx)
                })
            },
            yes: function (i, o) {
                var param = $('#form2').serialize()
                param += '&id='+id
                $.post('{:url("update")}', param, function (data) {
                    if (data.success) {
                        swal({title: data.msg}, function () {
                            layer.close(i)
                            location.reload()
                        })
                    } else {
                        swal(data.msg)
                    }
                }, 'json')
            }
        });
    })

    /**
     * 删除
     *
     * */
    $(".delete").click(function () {
        var id = $(this).data('id')
        swal({
                title: "",
                text: "确定删除！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                closeOnCancel: false
            },
            function (isConfirm) {
                if (isConfirm) {
                    $.post('{:url("delete")}', {id:id}, function (data) {
                        if (data.success) {
                            swal({title: data.msg}, function () {
                                location.reload()
                            })
                        } else {
                            swal(data.msg)
                        }
                    }, 'json')
                } else {
                    swal("取消！", "", "error");
                }
            });

    })

    $('#renyuan').on('click','.ren .close',function () {
        $(this).closest('.ren').remove()
    })

    //弹窗选择人员
    $('#select_area').on('click', function () {
        var index = layer.getFrameIndex(window.name)
        //iframe层-父子操作
        top.layer.open({
            type: 2,
            title: '请选择',
            area: ['500px', '400px'],
            fixed: false, //不固定
            maxmin: true,
            content: '{:url("open/employee")}?frameindex=' + index,
            btn:['确定','取消'],
            yes:function (i,o) {
                var a = $(o).find('iframe').contents()
                var data = a.find('#data')
                data = data.val()
                data = JSON.parse(data)
                var bool = false
                for(var j=0;j<data.length;j++){
                    $('#renyuan .ren').each(function (idx, o) {
                        if ($(this).data('id') == data[j].id) {
                            bool = true;
                        }
                    })
                    if (bool == false)
                        $('#renyuan').append('<span class="ren" data-id="' + data[j].id + '">' + data[j].title + '<span class="close">×</span><input type="hidden" name="ygxm[]" value="'+data[j].id+'"></span>')

                }
                top.layer.close(i)

            }
        })
        return false
    })

    /**
     * 员工姓名
     */
    $("#area_id").bsSuggest({
        url: "{:url('jxsgl/provicejson')}",
        /*effectiveFields: ["userName", "shortAccount"],
         searchFields: [ "shortAccount"],*/
        effectiveFieldsAlias: {userName: "姓名"},
        ignorecase: true,
        showHeader: true,
        showBtn: false,     //不显示下拉按钮
        delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
        idField: "id",
        keyField: "title",
        clearable: true
    }).on('onDataRequestSuccess', function (e, result) {
        console.log('onDataRequestSuccess: ', result);
    }).on('onSetSelectValue', function (e, keyword, data) {
        $(this).val('')
        var bool = false
        $('#renyuan .ren').each(function (idx, o) {
            if ($(this).data('id') == keyword.id) {
                bool = true;
            }
        })
        if (bool == false)
            $('#renyuan').append('<span class="ren" data-id="' + keyword.id + '">' + keyword.key + '<span class="close">×</span><input type="hidden" name="ygxm[]" value="'+keyword.id+'"></span>')
        //console.log('onSetSelectValue: ', keyword, data);
    }).on('onUnsetSelectValue', function () {
        console.log("onUnsetSelectValue");
    });

    laydate.render({
        elem: '#startsban',
        format: 'HH:mm',
        type: 'time'
    });
    laydate.render({
        elem: '#endxban',
        format: 'HH:mm',
        type: 'time'
    });

    var jieshou = $("#area_id");
    sousuo(jieshou);

    function sousuo(id) {
        id.bsSuggest({
            allowNoKeyword: false, //是否允许无关键字时请求数据
            multiWord: true, //以分隔符号分割的多关键字支持
            separator: ",", //多关键字支持时的分隔符，默认为空格
            getDataMethod: "url", //获取数据的方式，总是从 URL 获取
            url: 'http://unionsug.baidu.com/su?p=3&t=' + (new Date()).getTime() + '&wd=',
            /*优先从url ajax 请求 json 帮助数据，注意最后一个参数为关键字请求参数*/
            jsonp: 'cb',
            /*如果从 url 获取数据，并且需要跨域，则该参数必须设置*/
            processData: function (json) { // url 获取数据时，对数据的处理，作为 getData 的回调函数
                var i, len, data = {
                    value: []
                };
                if (!json || !json.s || json.s.length === 0) {
                    return false;
                }

                // console.log(json);
                len = json.s.length;

                jsonStr = "{'value':[";
                for (i = 0; i < len; i++) {
                    data.value.push({
                        word: json.s[i]
                    });
                }
                data.defaults = 'baidu';

                //字符串转化为 js 对象
                return data;
            }
        });

    }

</script>
</body>

</html>